package Cursus.Listeners;

import java.awt.*;
import java.io.*;
import javax.swing.*;

public class SwingJFileChooser extends JFrame {
    JLabel lab = new JLabel("Gewoon Tekst");

    public SwingJFileChooser() {
        setSize(400, 400);
        lab.setOpaque(true);
        Container c = getContentPane();
        c.setLayout(new FlowLayout());
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        c.add(lab);

        JFileChooser fc = new JFileChooser();

        int returnVal = fc.showOpenDialog(this);
        if(returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            String naam = file.getPath()+file.getName();
            lab.setText(naam);
        }

        setVisible(true);
    }

    public static void main(String args[]) {
        new SwingJFileChooser();
    }
}
